%% computes port clusters as connected subgraphs of a network where links are given to ports within 30 km radius of each other
%% use input generated by and produces output for NetworkCleaning.do

clear
workdir = '/Users/inga/Dropbox/Ais project/Repository';
fid = fopen(strcat(workdir,'/data_intermediate/network_close.csv'));
N = textscan(fid, '%d %d %f','delimiter',',');
fclose(fid);
s = N{1}; d = N{2};
G = graph(s,d);
plot(G)

bins = conncomp(G); %entry indicates which bin every port (cell) belongs to
dlmwrite(strcat(workdir,'/data_intermediate/connectedcomp.csv'),bins')